<template>
  <div id="slidebar">
    <ul>
      <li
        :class="$route.path === item.toPath?'active':''"
        class="item" @click="handleClick(item.toPath)" :key="item.path" v-for="(item,index) in asideData">
        {{item.title}}

      </li>
    </ul>

  </div>
</template>

<script>
  import {getAsideData} from '@/routes/router-config.js'

  export default {
    name: "SlideBar",
    computed: {
      asideData() {
        return getAsideData();
      }
    },

    methods: {
      handleClick(path) {
        if (path === this.$route.fullPath) {
          return
        }
        // console.log(path)
        this.$router.push(path);
      }
    },
    created() {
      // console.log(this.$route);//  人的属性    路由的属性
      // console.log(this.$router); // 人的动作   路由的操作
    }
  }
</script>

<style scoped>

  #slidebar {
    width: 200px;
    background: #ff605a;
    /*height: 100%;*/

    position: absolute;
    left: 0;
    overflow-y: auto;
    top: 81px;
    bottom: 0;
    border-right: 1px solid #cccccc;
  }

  .item {
    text-align: center;
    line-height: 40px;
    background-color: #d4ebd0;
    list-style: none;
    margin-bottom: 1px;
    height: 40px;
    cursor: pointer;

  }

  li:hover, li.active {
    background-color: #00a8cc;
    color: #fff;
  }

</style>
